<template>
  <div>
    <ul>
      <li v-for="(item,index) in arr" :key="index">{{item}} <button @click="delArr(index)">删除</button></li>
    </ul>
    <button @click="addArr">生成</button>
  </div>
</template>

<script>
export default {
  data () {
    return {
      arr: [1, 5, 2, 7]
    }
  },

  created () {

  },

  methods: {
    addArr () {
      const i = Math.round(Math.random() * 100)
      this.arr.push(i)
    },
    delArr (n) {
      this.arr.splice(n, 1)
    }
  }
}
</script>

<style scoped lang='less'>

</style>
